﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Interface_Design
{
    public partial class SettingsForm : Form
    {
        IniFile iniFile = new IniFile(@"..\..\Configuration\settingsForm.ini");

        public SettingsForm()
        {
            InitializeComponent();
            readSettingsFromINI();
        }

        private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                // Cancel the close and hide the form
                e.Cancel = true;
                this.Hide();
            }
        }

        private void setKinectTiltButton_Click(object sender, EventArgs e)
        {
            if (kinectTiltUpDown.Value > 27)
                kinectTiltUpDown.Value = 27;
            else if (kinectTiltUpDown.Value < -27)
                kinectTiltUpDown.Value = -27;

            int value = (int)kinectTiltUpDown.Value;

            // perform tilt
        }

        private void saveSettingsButton_Click(object sender, EventArgs e)
        {
            //Write the data to the 
            writeSettingsToINI();
        }

        private void writeSettingsToINI()
        {
            iniFile.IniWriteValue("General", "systemStart", systemStartCheckBox.Checked.ToString());
            iniFile.IniWriteValue("General", "mouseControlOnStart", mouseControlCheckBox.Checked.ToString());
            iniFile.IniWriteValue("General", "showDepthStream", showDepthStreamCheckBox.Checked.ToString());
            iniFile.IniWriteValue("General", "showSkeletalTracking", showSkeletalTrackingCheckBox.Checked.ToString());
        }

        private void readSettingsFromINI()
        {
            systemStartCheckBox.Checked = Boolean.Parse(iniFile.IniReadValue("General", "systemStart"));
            mouseControlCheckBox.Checked = Boolean.Parse(iniFile.IniReadValue("General", "mouseControlOnStart"));
            showDepthStreamCheckBox.Checked = Boolean.Parse(iniFile.IniReadValue("General", "showDepthStream"));
            showSkeletalTrackingCheckBox.Checked = Boolean.Parse(iniFile.IniReadValue("General", "showSkeletalTracking"));
        }

    }
}
